import pyglet
pyglet.options['debug_gl'] = False
from pyglet.gl import *

class Intro(object):
    def __init__(self,g):
        self.g=g
        self.ani=g.LoadAni('hud/rays.gif')
        self.ani.set_position((g.width-self.ani.width)//2,(g.height-self.ani.height)//2+self.ani.height)
        self.prod=g.LoadImg('hud/title.png')
        self.prod.set_position(g.width//2,g.height//2)
        self.pres=g.LoadImg('hud/present.png')
        self.pres.set_position(g.width//2,g.height//2)
        self.front=g.LoadImg('hud/front.png')
        self.front.set_position(g.width//2,g.height//2)

        self.alpha=1.0

        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
        glEnable(GL_BLEND)
        glDisable(GL_DEPTH_TEST)

    def Black(self,x,y,width,height,color):
        glBegin(GL_QUADS)
        glColor4f(*color)
        glVertex2i(x, y)
        glVertex2i(x + width, y)
        glVertex2i(x + width, y + height)
        glVertex2i(x, y + height)
        glEnd()
       
    def Draw(self):
        if self.g.state & (self.g.INTRO1 | self.g.INTRO2):
            self.ani.draw()
            self.prod.draw()
            self.Black(0,0,self.g.width,self.g.height,(0,0,0,self.alpha))
        if self.g.state & (self.g.INTRO3 | self.g.INTRO4):
            self.pres.draw()
            self.Black(0,0,self.g.width,self.g.height,(0,0,0,self.alpha))
        if self.g.state & self.g.INTRO5:
            self.front.draw()
            self.g.hud.l_fvs.draw()
            self.g.hud.l_cont.draw()
        if self.g.state & self.g.CREDITS:
            self.g.hud.l_end1.draw()
            self.g.hud.l_end2.draw()
            self.g.hud.l_end3.draw()
            self.g.hud.l_end4.draw()
            self.g.hud.l_end5.draw()
            self.g.hud.l_end6.draw()
            self.g.hud.l_end7.draw()
            self.g.hud.l_end8.draw()
            self.g.hud.l_end9.draw()
            self.g.hud.l_end10.draw()
            
